# 字符串 O(N)

class Solution:
    def isSumEqual(self, firstWord: str, secondWord: str, targetWord: str) -> bool:
        n1 = 0
        n2 = 0
        n3 = 0
        for i in range(len(firstWord)):
            n1 = n1 * 10 + (ord(firstWord[i]) - 97)
        for i in range(len(secondWord)):
            n2 = n2 * 10 + (ord(secondWord[i]) - 97)
        for i in range(len(targetWord)):
            n3 = n3 * 10 + (ord(targetWord[i]) - 97)

        return n1 + n2 == n3


if __name__ == "__main__":
    print(Solution().isSumEqual(firstWord="acb", secondWord="cba", targetWord="cdb"))  # True
    print(Solution().isSumEqual(firstWord="aaa", secondWord="a", targetWord="aab"))  # False
    print(Solution().isSumEqual(firstWord="aaa", secondWord="a", targetWord="aaaa"))  # True
